<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #ggg {
            width: 400px;
            height: 100px;
            position: relative;
            /* 文字不能被选中 */
            user-select: none;
            border: 1px solid #000;
        }
        
        #ggg .jp {
            width: 400px;
            height: 100px;
            position: absolute;
            top: 10px;
            left: 50px;
            color: aqua;
            line-height: 100px;
            font-size: 30px;
        }
        
        #ggg #myCanvas {
            width: 400px;
            height: 100px;
            position: absolute;
            top:0px;
            left:0px;
        }
    </style>
</head>

<body>
    <div id="ggg">
        <div class="jp">谢谢惠顾</div>
        <canvas id="myCanvas"></canvas>
    </div>

    <script>
        var c = document.getElementById("myCanvas");
        var gg = document.getElementById('ggg')
        var ctx = c.getContext("2d");
        ctx.fillStyle = "darkgray"
        ctx.fillRect(0, 0, 200, 150)

        let isDe = false;
        c.onmousedown = function() {
            isDe = true;
        }
        c.onmousemove = function(e) {
            if (isDe) {
                var x = e.pageX - gg.offsetLeft;
                var y = e.pageY - gg.offsetTop;
                console.log(x, y);
                ctx.fillStyle = "#fff";
                ctx.globalCompositeOperation = "destination-out";
                ctx.arc(x, y, 20, 0, 2 * Math.PI);
                ctx.fill()
            }
        }
        c.onmouseup = function() {
            isDe = false;
        }
    </script>
</body>

</html>